package com.jfinal.enjoy

import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.options.colors.AttributesDescriptor
import com.intellij.openapi.options.colors.ColorSettingsPage
import javax.swing.Icon

class EnjoyColorSettingsPage : ColorSettingsPage {

    override fun getDisplayName(): String = "Enjoy Template"

    override fun getIcon(): Icon = EnjoyIcons.FILE

    override fun getHighlighter() = EnjoySyntaxHighlighter()

    override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
        return arrayOf(
            AttributesDescriptor("Keyword", EnjoySyntaxHighlighter.KEYWORD),
            AttributesDescriptor("String", EnjoySyntaxHighlighter.STRING),
            AttributesDescriptor("Number", EnjoySyntaxHighlighter.NUMBER),
            AttributesDescriptor("Identifier", EnjoySyntaxHighlighter.IDENTIFIER),
            AttributesDescriptor("LineComment", EnjoySyntaxHighlighter.COMMENT),
            AttributesDescriptor("BlockComment", EnjoySyntaxHighlighter.BLOCK_COMMENT),
            AttributesDescriptor("Operator", EnjoySyntaxHighlighter.OPERATOR)
        )
    }

    override fun getColorDescriptors() = emptyArray<com.intellij.openapi.options.colors.ColorDescriptor>()

    override fun getDemoText(): String {
        // 这里的内容会在颜色配置界面显示预览
        return """
            ### This is a line comment
            #-- This is a block comment --#

        """.trimIndent()
    }

    override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey>? {
        // 如果 demoText 里想用 <tag>xxx</tag> 手动高亮，可以在这里映射
        return null
    }
}
